#line 2 "F:\Emergent\Gamebryo-2.6-Source\Samples\Demos\TerrainDemo\Data\Shaders\Generated\NiTerrainMaterial\000000ED-0055F541-00000000-00010000-P.hlsl"
/*
Shader description:
WORLDNBT = 1
NUM_TEXCOORDS = 1
NUM_LAYERS = 4
LAYER0_NORMAL_ENABLED = 1
LAYER0_PARALLAX_ENABLED = 0
LAYER0_DISTMASK_ENABLED = 1
LAYER0_DETAIL_ENABLED = 0
LAYER0_UVINDEX = 0
LAYER1_NORMAL_ENABLED = 1
LAYER1_PARALLAX_ENABLED = 1
LAYER1_DISTMASK_ENABLED = 1
LAYER1_DETAIL_ENABLED = 1
LAYER1_UVINDEX = 0
LAYER2_NORMAL_ENABLED = 1
LAYER2_PARALLAX_ENABLED = 0
LAYER2_DISTMASK_ENABLED = 1
LAYER2_DETAIL_ENABLED = 0
LAYER2_UVINDEX = 0
LAYER3_NORMAL_ENABLED = 1
LAYER3_PARALLAX_ENABLED = 0
LAYER3_DISTMASK_ENABLED = 1
LAYER3_DETAIL_ENABLED = 0
LAYER3_UVINDEX = 0
LAYER4_NORMAL_ENABLED = 0
LAYER4_PARALLAX_ENABLED = 0
LAYER4_DISTMASK_ENABLED = 0
LAYER4_DETAIL_ENABLED = 0
LAYER4_UVINDEX = 0
LAYER5_NORMAL_ENABLED = 0
LAYER5_PARALLAX_ENABLED = 0
LAYER5_DISTMASK_ENABLED = 0
LAYER5_DETAIL_ENABLED = 0
LAYER5_UVINDEX = 0
LAYER6_NORMAL_ENABLED = 0
LAYER6_PARALLAX_ENABLED = 0
LAYER6_DISTMASK_ENABLED = 0
LAYER6_DETAIL_ENABLED = 0
LAYER6_UVINDEX = 0
LAYER7_NORMAL_ENABLED = 0
LAYER7_PARALLAX_ENABLED = 0
LAYER7_DISTMASK_ENABLED = 0
LAYER7_DETAIL_ENABLED = 0
LAYER7_UVINDEX = 0
*/

//---------------------------------------------------------------------------
// Types:
#if defined(DIRECT3D)
#define BONEMATRIX_TYPE float4x3
#else
#define BONEMATRIX_TYPE float3x4
#endif
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Constant variables:
//---------------------------------------------------------------------------

sampler2D BlendMap0;
float4 g_SurfaceUVModifierArray[4];
sampler2D DistributionMap0;
float4 g_DistMaskStrength;
sampler2D NormalMap1;
sampler2D BaseMap0;
sampler2D NormalMap0;
sampler2D BaseMap1;
sampler2D BaseMap2;
sampler2D NormalMap2;
sampler2D BaseMap3;
sampler2D NormalMap3;
float4 g_DirWorldDirection0;
float4 g_DirDiffuse0;
float4 g_DirAmbient0;
float4 g_FogColor;
//---------------------------------------------------------------------------
// Functions:
//---------------------------------------------------------------------------

/*

      Normalizes the specified 3D vector.
    
*/

void NormalizeVector(float3 Input,
    out float3 Output)
{

      Output = normalize(Input);
    
}
//---------------------------------------------------------------------------
/*

      This fragment extracts the scale and offset parameters for the specified
      surface from the UV Modifier arrays.
    
*/

void AccessSurfaceUVModifiersArray(float4 UVModifierArray[4],
    int Index,
    out float2 OutputScale,
    out float2 OutputOffset)
{

      OutputScale.xy = UVModifierArray[Index].xy;
      OutputOffset.xy = UVModifierArray[Index].zw;
    
}
//---------------------------------------------------------------------------
/*

      This fragment samples an RGBA texture and returns each component where 
      each component contains a mask for a given texture layer.
    
*/

void SampleBlendMap(float4 MapUV,
    sampler2D Sampler,
    out float OutputRed,
    out float OutputGreen,
    out float OutputBlue,
    out float OutputAlpha,
    out float TotalMask)
{

      float4 color = tex2D(Sampler, MapUV.zw);
      OutputRed = color.r;
      OutputGreen = color.g;
      OutputBlue = color.b;
      OutputAlpha = color.a;
      TotalMask = dot(color, float4(1,1,1,1));
    
}
//---------------------------------------------------------------------------
/*

      This fragment scales and offsets a uv texture coordinate value. 
      Usefull for linearly modifying a texture coordinate. Used by a surface
      to modify its texture coordinates independantly of the other surfaces.
    
*/

void CalcSurfaceUVSet_ScaleAndOffset(float4 InputUV,
    float2 Scale,
    float2 Offset,
    out float4 OutputUV)
{

      OutputUV.x = InputUV.x * Scale.x + Offset.x;
      OutputUV.y = InputUV.y * Scale.y + Offset.y;
      OutputUV.z = InputUV.z * Scale.x + Offset.x;
      OutputUV.w = InputUV.w * Scale.y + Offset.y;
    
}
//---------------------------------------------------------------------------
/*

      This sample samples a channel based on the specified index (0 - 3).
    
*/

void SampleSingleChannel(float4 MapUV,
    sampler2D Sampler,
    int ChannelIndex,
    out float Output)
{

      if (ChannelIndex == 0)
        Output = tex2D(Sampler, MapUV.xy).r;
      else if (ChannelIndex == 1)
        Output =  tex2D(Sampler, MapUV.xy).g;
      else if (ChannelIndex == 2)
        Output =  tex2D(Sampler, MapUV.xy).b;
      else if (ChannelIndex == 3)
        Output =  tex2D(Sampler, MapUV.xy).a;
      
    
}
//---------------------------------------------------------------------------
/*

      This fragment is responsible for transforming a vector from world space
      to tangent space.
    
*/

void WorldToTangent(float3 VectorIn,
    float3 WorldNormal,
    float3 WorldBinormal,
    float3 WorldTangent,
    out float3 VectorOut)
{

      float3x3 xForm = float3x3(WorldTangent, WorldBinormal, WorldNormal);
      VectorOut = mul(xForm, VectorIn);
    
}
//---------------------------------------------------------------------------
/*

      This fragment multiplies a single floating point value by a mask value from 0.0 - 1.0 and
      adds the result to the additional input.
    
*/

void CalcBlendFloatAndAccumulate(float Mask,
    float Input,
    float AccumValue,
    out float Output)
{

      Output = AccumValue + (Mask * Input);
    
}
//---------------------------------------------------------------------------
/*

    This fragment is responsible for linearly interpolating two float3's. 
    
*/

void InverseRatio(float Ratio,
    out float Output)
{

    Output = 1.0 - Ratio;
    
}
//---------------------------------------------------------------------------
/*

      This fragment combines mask values from the "global" mask with per layer 
      mask to produce a final composited mask.
    
*/

void ComputeTotalMaskValue(float lMask0,
    float lMask1,
    float lMask2,
    float lMask3,
    float gMask0,
    float gMask1,
    float gMask2,
    float gMask3,
    float4 DistStrength,
    out float gMask0_Out,
    out float gMask1_Out,
    out float gMask2_Out,
    out float gMask3_Out)
{

                    
          float4 gMaskTotal = float4(gMask0, gMask1, gMask2, gMask3);
          float4 lMaskTotal = float4(lMask0, lMask1, lMask2, lMask3);
          
          float4 value = gMaskTotal * lMaskTotal * DistStrength;
          float4 result = normalize(gMaskTotal + lerp(float4(0.0f, 0.0f, 0.0f, 0.0f), 
            lMaskTotal, value));
          
          gMask0_Out = result.x;
          gMask1_Out = result.y;
          gMask2_Out = result.z;
          gMask3_Out = result.w;
    
}
//---------------------------------------------------------------------------
/*

      This fragment samples the alpha channel of the specified texture.
    
*/

void SampleLayerTextureAlpha(float4 MapUV,
    sampler2D Sampler,
    out float OutputAlpha)
{

      OutputAlpha = tex2D(Sampler, MapUV.xy).a;
    
}
//---------------------------------------------------------------------------
/*

      This fragment is responsible for calculating the UV offset to apply
      as a result of a parallax map.
    
*/

void CalculateParallaxOffset(float4 TexCoord,
    float Height,
    float OffsetScale,
    float3 TangentSpaceEyeVec,
    out float4 ParallaxOffsetUV)
{

      // Calculate offset scaling constant bias.
      float2 Bias = float2(OffsetScale, OffsetScale) * -0.5;

      // Calculate offset
      float2 Offset = float2(Height, Height) * OffsetScale + Bias;

      // Get texcoord.
      ParallaxOffsetUV = float4(TexCoord.xy + Offset * TangentSpaceEyeVec.xy, 
        TexCoord.zw);
    
}
//---------------------------------------------------------------------------
/*

      This fragment samples an RGB texture for a given terrain layer and
      returns the float3 value.
    
*/

void SampleLayerTextureRGB(float4 MapUV,
    sampler2D Sampler,
    out float3 OutputColor)
{

      OutputColor = tex2D(Sampler, MapUV.xy).rgb;
    
}
//---------------------------------------------------------------------------
/*

      Computes UV coordinates by multiplying the xy components of the input float4
      and a scale factor.
    
*/

void ScaleUVForDetailMap(float4 MapUV,
    float ScaleFactor,
    out float2 OutputUV)
{
      
      OutputUV = MapUV.xy * ScaleFactor;
    
}
//---------------------------------------------------------------------------
/*

      This fragment is responsible for sampling a normal map to generate a
      world-space normal. Note, compressed normal maps are not supported.
    
*/

void CalculateNormalFromColor(float3 NormalMap,
    float3 WorldNormal,
    float3 WorldBinormal,
    float3 WorldTangent,
    out float3 WorldNormalOut)
{

      NormalMap = NormalMap * 2.0 - 1.0;

      float3x3 xForm = float3x3(WorldTangent, WorldBinormal, WorldNormal);
      xForm = transpose(xForm);
      WorldNormalOut = mul(xForm, NormalMap.rgb);
    
}
//---------------------------------------------------------------------------
/*

      Samples an RGBA texture where the RGB channels contain the base map 
      information and the alpha channel contains the detail map data. The detail
      map is sampled at a much higher frequency that the base map.
    
*/

void SampleBaseMapWithDetailMap(float4 MapUV,
    float2 DetailMapUV,
    sampler2D Sampler,
    out float4 OutputColor)
{
      
      float3 base = tex2D(Sampler, MapUV.xy);
      float detail = tex2D(Sampler, DetailMapUV).a;      
      OutputColor = float4(base, detail);
    
}
//---------------------------------------------------------------------------
/*

      This fragment multiplies an RGB color by a mask value from 0.0 - 1.0 and
      adds the result to the additional input.
    
*/

void CalcBlendRGBAndAccumulate(float Mask,
    float3 InputColor,
    float3 AccumColor,
    out float3 OutputColor)
{

      OutputColor = AccumColor + (InputColor * Mask);
    
}
//---------------------------------------------------------------------------
/*

      This fragment multiplies an RGBA color by a mask value from 0.0 - 1.0 and
      adds the result to the additional input. The RGB and A channels are
      seperated where the A channel represents a detail mask value.
    
*/

void CalcBlendBaseMapWithDetailMap(float Mask,
    float4 InputColor,
    float3 AccumColor,
    out float3 OutputColor)
{

      OutputColor = AccumColor + (InputColor.rgb * Mask * 2 * InputColor.a);
    
}
//---------------------------------------------------------------------------
/*
            
      WorldNormal and LightDirection are assumed to be normalized.
    
*/

void AccumulateLight(float3 WorldNormal,
    float3 LightDirection,
    float3 LightDiffuse,
    float3 LightAmbient,
    float3 DiffuseAccum,
    out float3 OutputDiffuse)
{

      
      float NdotL = saturate(dot(WorldNormal, -LightDirection));
      OutputDiffuse = DiffuseAccum + LightAmbient;
      OutputDiffuse += LightDiffuse * NdotL;
    
}
//---------------------------------------------------------------------------
/*

      This fragment is responsible for computing the final RGBA color by applying
      the lighting model used for the terrain.
    
*/

void CompositeFinalColor(float3 DiffuseColor,
    float3 DiffuseFactor,
    out float4 OutputColor)
{

      OutputColor = float4(DiffuseColor * DiffuseFactor, 1.0);
    
}
//---------------------------------------------------------------------------
/*

      This fragment is responsible for applying the fog amount.
    
*/

void ApplyFog(float4 UnfoggedColor,
    float3 FogColor,
    float FogAmount,
    out float4 FoggedColor)
{

      FoggedColor = float4(lerp(FogColor, UnfoggedColor.rgb, FogAmount), 1.0);
    
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Input:
//---------------------------------------------------------------------------

struct Input
{
    float4 PosProjected : POSITION0;
    float4 UVSet0 : TEXCOORD0;
    float3 WorldView : TEXCOORD1;
    float3 WorldNormal : TEXCOORD2;
    float3 WorldBinormal : TEXCOORD3;
    float3 WorldTangent : TEXCOORD4;
    float FogDepth : FOG0;

};

//---------------------------------------------------------------------------
// Output:
//---------------------------------------------------------------------------

struct Output
{
    float4 Color0 : COLOR0;

};

//---------------------------------------------------------------------------
// Main():
//---------------------------------------------------------------------------

Output Main(Input In)
{
    Output Out;
	// Function call #0
    float3 Output_CallOut0;
    NormalizeVector(In.WorldView, Output_CallOut0);

	// Function call #1
    float3 Output_CallOut1;
    NormalizeVector(In.WorldTangent, Output_CallOut1);

	// Function call #2
    float3 Output_CallOut2;
    NormalizeVector(In.WorldTangent, Output_CallOut2);

	// Function call #3
    float3 Output_CallOut3;
    NormalizeVector(In.WorldTangent, Output_CallOut3);

	// Function call #4
    float3 Output_CallOut4;
    NormalizeVector(In.WorldTangent, Output_CallOut4);

	// Function call #5
    float3 Output_CallOut5;
    NormalizeVector(In.WorldNormal, Output_CallOut5);

	// Function call #6
    float2 OutputScale_CallOut6;
    float2 OutputOffset_CallOut6;
    AccessSurfaceUVModifiersArray(g_SurfaceUVModifierArray, int(0), 
        OutputScale_CallOut6, OutputOffset_CallOut6);

	// Function call #7
    float2 OutputScale_CallOut7;
    float2 OutputOffset_CallOut7;
    AccessSurfaceUVModifiersArray(g_SurfaceUVModifierArray, int(1), 
        OutputScale_CallOut7, OutputOffset_CallOut7);

	// Function call #8
    float2 OutputScale_CallOut8;
    float2 OutputOffset_CallOut8;
    AccessSurfaceUVModifiersArray(g_SurfaceUVModifierArray, int(2), 
        OutputScale_CallOut8, OutputOffset_CallOut8);

	// Function call #9
    float2 OutputScale_CallOut9;
    float2 OutputOffset_CallOut9;
    AccessSurfaceUVModifiersArray(g_SurfaceUVModifierArray, int(3), 
        OutputScale_CallOut9, OutputOffset_CallOut9);

	// Function call #10
    float3 Output_CallOut10;
    NormalizeVector(In.WorldBinormal, Output_CallOut10);

	// Function call #11
    float3 Output_CallOut11;
    NormalizeVector(In.WorldBinormal, Output_CallOut11);

	// Function call #12
    float3 Output_CallOut12;
    NormalizeVector(In.WorldBinormal, Output_CallOut12);

	// Function call #13
    float3 Output_CallOut13;
    NormalizeVector(In.WorldBinormal, Output_CallOut13);

	// Function call #14
    float OutputRed_CallOut14;
    float OutputGreen_CallOut14;
    float OutputBlue_CallOut14;
    float OutputAlpha_CallOut14;
    float TotalMask_CallOut14;
    SampleBlendMap(In.UVSet0, BlendMap0, OutputRed_CallOut14, 
        OutputGreen_CallOut14, OutputBlue_CallOut14, OutputAlpha_CallOut14, 
        TotalMask_CallOut14);

	// Function call #15
    float4 OutputUV_CallOut15;
    CalcSurfaceUVSet_ScaleAndOffset(In.UVSet0, OutputScale_CallOut6, 
        OutputOffset_CallOut6, OutputUV_CallOut15);

	// Function call #16
    float4 OutputUV_CallOut16;
    CalcSurfaceUVSet_ScaleAndOffset(In.UVSet0, OutputScale_CallOut8, 
        OutputOffset_CallOut8, OutputUV_CallOut16);

	// Function call #17
    float Output_CallOut17;
    SampleSingleChannel(OutputUV_CallOut15, DistributionMap0, int(0), 
        Output_CallOut17);

	// Function call #18
    float Output_CallOut18;
    SampleSingleChannel(OutputUV_CallOut16, DistributionMap0, int(2), 
        Output_CallOut18);

	// Function call #19
    float3 VectorOut_CallOut19;
    WorldToTangent(Output_CallOut0, Output_CallOut5, Output_CallOut10, 
        Output_CallOut1, VectorOut_CallOut19);

	// Function call #20
    float3 VectorOut_CallOut20;
    WorldToTangent(Output_CallOut0, Output_CallOut5, Output_CallOut11, 
        Output_CallOut2, VectorOut_CallOut20);

	// Function call #21
    float3 VectorOut_CallOut21;
    WorldToTangent(Output_CallOut0, Output_CallOut5, Output_CallOut12, 
        Output_CallOut3, VectorOut_CallOut21);

	// Function call #22
    float3 VectorOut_CallOut22;
    WorldToTangent(Output_CallOut0, Output_CallOut5, Output_CallOut13, 
        Output_CallOut4, VectorOut_CallOut22);

	// Function call #23
    float Output_CallOut23;
    CalcBlendFloatAndAccumulate(TotalMask_CallOut14, float(1), float(0), 
        Output_CallOut23);

	// Function call #24
    float4 OutputUV_CallOut24;
    CalcSurfaceUVSet_ScaleAndOffset(In.UVSet0, OutputScale_CallOut9, 
        OutputOffset_CallOut9, OutputUV_CallOut24);

	// Function call #25
    float Output_CallOut25;
    SampleSingleChannel(OutputUV_CallOut24, DistributionMap0, int(3), 
        Output_CallOut25);

	// Function call #26
    float Output_CallOut26;
    InverseRatio(Output_CallOut23, Output_CallOut26);

	// Function call #27
    float4 OutputUV_CallOut27;
    CalcSurfaceUVSet_ScaleAndOffset(In.UVSet0, OutputScale_CallOut7, 
        OutputOffset_CallOut7, OutputUV_CallOut27);

	// Function call #28
    float Output_CallOut28;
    SampleSingleChannel(OutputUV_CallOut27, DistributionMap0, int(1), 
        Output_CallOut28);

	// Function call #29
    float gMask0_Out_CallOut29;
    float gMask1_Out_CallOut29;
    float gMask2_Out_CallOut29;
    float gMask3_Out_CallOut29;
    ComputeTotalMaskValue(Output_CallOut17, Output_CallOut28, Output_CallOut18, 
        Output_CallOut25, OutputRed_CallOut14, OutputGreen_CallOut14, 
        OutputBlue_CallOut14, OutputAlpha_CallOut14, g_DistMaskStrength, 
        gMask0_Out_CallOut29, gMask1_Out_CallOut29, gMask2_Out_CallOut29, 
        gMask3_Out_CallOut29);

	// Function call #30
    float OutputAlpha_CallOut30;
    SampleLayerTextureAlpha(OutputUV_CallOut27, NormalMap1, 
        OutputAlpha_CallOut30);

	// Function call #31
    float Output_CallOut31;
    CalcBlendFloatAndAccumulate(gMask1_Out_CallOut29, OutputAlpha_CallOut30, 
        float(0), Output_CallOut31);

	// Function call #32
    float4 ParallaxOffsetUV_CallOut32;
    CalculateParallaxOffset(OutputUV_CallOut27, Output_CallOut31, float(0.05), 
        VectorOut_CallOut20, ParallaxOffsetUV_CallOut32);

	// Function call #33
    float3 OutputColor_CallOut33;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut32, NormalMap1, 
        OutputColor_CallOut33);

	// Function call #34
    float4 ParallaxOffsetUV_CallOut34;
    CalculateParallaxOffset(OutputUV_CallOut16, Output_CallOut31, float(0.05), 
        VectorOut_CallOut21, ParallaxOffsetUV_CallOut34);

	// Function call #35
    float3 OutputColor_CallOut35;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut34, NormalMap2, 
        OutputColor_CallOut35);

	// Function call #36
    float4 ParallaxOffsetUV_CallOut36;
    CalculateParallaxOffset(OutputUV_CallOut24, Output_CallOut31, float(0.05), 
        VectorOut_CallOut22, ParallaxOffsetUV_CallOut36);

	// Function call #37
    float3 OutputColor_CallOut37;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut36, NormalMap3, 
        OutputColor_CallOut37);

	// Function call #38
    float4 ParallaxOffsetUV_CallOut38;
    CalculateParallaxOffset(OutputUV_CallOut15, Output_CallOut31, float(0.05), 
        VectorOut_CallOut19, ParallaxOffsetUV_CallOut38);

	// Function call #39
    float3 OutputColor_CallOut39;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut38, NormalMap0, 
        OutputColor_CallOut39);

	// Function call #40
    float2 OutputUV_CallOut40;
    ScaleUVForDetailMap(ParallaxOffsetUV_CallOut32, float(8.0), 
        OutputUV_CallOut40);

	// Function call #41
    float3 WorldNormalOut_CallOut41;
    CalculateNormalFromColor(OutputColor_CallOut33, Output_CallOut5, 
        Output_CallOut11, Output_CallOut2, WorldNormalOut_CallOut41);

	// Function call #42
    float3 OutputColor_CallOut42;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut34, BaseMap2, 
        OutputColor_CallOut42);

	// Function call #43
    float3 WorldNormalOut_CallOut43;
    CalculateNormalFromColor(OutputColor_CallOut35, Output_CallOut5, 
        Output_CallOut12, Output_CallOut3, WorldNormalOut_CallOut43);

	// Function call #44
    float3 OutputColor_CallOut44;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut36, BaseMap3, 
        OutputColor_CallOut44);

	// Function call #45
    float3 WorldNormalOut_CallOut45;
    CalculateNormalFromColor(OutputColor_CallOut37, Output_CallOut5, 
        Output_CallOut13, Output_CallOut4, WorldNormalOut_CallOut45);

	// Function call #46
    float3 OutputColor_CallOut46;
    SampleLayerTextureRGB(ParallaxOffsetUV_CallOut38, BaseMap0, 
        OutputColor_CallOut46);

	// Function call #47
    float3 WorldNormalOut_CallOut47;
    CalculateNormalFromColor(OutputColor_CallOut39, Output_CallOut5, 
        Output_CallOut10, Output_CallOut1, WorldNormalOut_CallOut47);

	// Function call #48
    float4 OutputColor_CallOut48;
    SampleBaseMapWithDetailMap(ParallaxOffsetUV_CallOut32, OutputUV_CallOut40, 
        BaseMap1, OutputColor_CallOut48);

	// Function call #49
    float3 OutputColor_CallOut49;
    CalcBlendRGBAndAccumulate(gMask0_Out_CallOut29, OutputColor_CallOut46, 
        float3(0,0,0), OutputColor_CallOut49);

	// Function call #50
    float3 OutputColor_CallOut50;
    CalcBlendBaseMapWithDetailMap(gMask1_Out_CallOut29, OutputColor_CallOut48, 
        OutputColor_CallOut49, OutputColor_CallOut50);

	// Function call #51
    float3 OutputColor_CallOut51;
    CalcBlendRGBAndAccumulate(gMask2_Out_CallOut29, OutputColor_CallOut42, 
        OutputColor_CallOut50, OutputColor_CallOut51);

	// Function call #52
    float3 OutputColor_CallOut52;
    CalcBlendRGBAndAccumulate(gMask3_Out_CallOut29, OutputColor_CallOut44, 
        OutputColor_CallOut51, OutputColor_CallOut52);

	// Function call #53
    float3 OutputColor_CallOut53;
    CalcBlendRGBAndAccumulate(Output_CallOut26, float3(1,1,1), 
        OutputColor_CallOut52, OutputColor_CallOut53);

	// Function call #54
    float3 OutputColor_CallOut54;
    CalcBlendRGBAndAccumulate(gMask0_Out_CallOut29, WorldNormalOut_CallOut47, 
        float3(0,0,0), OutputColor_CallOut54);

	// Function call #55
    float3 OutputColor_CallOut55;
    CalcBlendRGBAndAccumulate(gMask1_Out_CallOut29, WorldNormalOut_CallOut41, 
        OutputColor_CallOut54, OutputColor_CallOut55);

	// Function call #56
    float3 OutputColor_CallOut56;
    CalcBlendRGBAndAccumulate(gMask2_Out_CallOut29, WorldNormalOut_CallOut43, 
        OutputColor_CallOut55, OutputColor_CallOut56);

	// Function call #57
    float3 OutputColor_CallOut57;
    CalcBlendRGBAndAccumulate(gMask3_Out_CallOut29, WorldNormalOut_CallOut45, 
        OutputColor_CallOut56, OutputColor_CallOut57);

	// Function call #58
    float3 OutputColor_CallOut58;
    CalcBlendRGBAndAccumulate(Output_CallOut26, Output_CallOut5, 
        OutputColor_CallOut57, OutputColor_CallOut58);

	// Function call #59
    float3 Output_CallOut59;
    NormalizeVector(OutputColor_CallOut58, Output_CallOut59);

	// Function call #60
    float3 OutputDiffuse_CallOut60;
    AccumulateLight(Output_CallOut59, g_DirWorldDirection0, g_DirDiffuse0, 
        g_DirAmbient0, float3(0.0, 0.0, 0.0), OutputDiffuse_CallOut60);

	// Function call #61
    float4 OutputColor_CallOut61;
    CompositeFinalColor(OutputColor_CallOut53, OutputDiffuse_CallOut60, 
        OutputColor_CallOut61);

	// Function call #62
    ApplyFog(OutputColor_CallOut61, g_FogColor, In.FogDepth, Out.Color0);

    return Out;
}

